From 96bbf3a3af45d86f790afdf91a6686c37421e92b Mon Sep 17 00:00:00 2001
From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Date: Sun, 15 Nov 2020 10:57:37 +0100
Subject: [PATCH] meson.build: check for pthread.h

Check for pthread.h otherwise the build will fail with some toolchains
that have libphtread.so but not pthread.h:

Run-time dependency threads found: YES

../src/hb-mutex.hh:53:10: fatal error: pthread.h: No such file or directory
 #include <pthread.h>
          ^~~~~~~~~~~

Moreover, fix detection of pthread fallback

Fixes:
 - http://autobuild.buildroot.org/results/70c98e89b1d5e5b651d1f6928dc53f465103f57a

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 meson.build | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index bf3925db..6d263d48 100644
--- a/meson.build
+++ b/meson.build
@@ -270,7 +270,9 @@ endif
 # threads
 thread_dep = null_dep
 if host_machine.system() != 'windows'
-  thread_dep = dependency('threads', required: false)
+  if cpp.has_header('pthread.h')
+    thread_dep = dependency('threads', required: false)
+  endif
 
   if thread_dep.found()
     conf.set('HAVE_PTHREAD', 1)
-- 
2.29.2

